<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

function ulang($line) {
    return ucfirst(lang($line));
}

function alertjs($texto){
    return "<script>alert('".$texto."');</script>";
}

function get_toolbar($accion = array()){
    $CI = & get_instance();
    return $CI->load->view('back/intro', $accion, true);
}

function get_uri_string(){
    $CI = & get_instance();
    if($CI->router->carpeta != null){ //si el controlador esta en una carpeta...
        return $CI->router->module."/".$CI->router->carpeta."/". $CI->router->class;
    }else{ //si el controlador no está en una carpeta
        return $CI->router->module."/".$CI->router->class."/".$CI->router->method;
    }
}

function get_alert($success = null, $error = null){
    $CI = & get_instance();
    $cadena = '';
    if($error != null || $CI->session->flashdata('error') != ''){
        $cadena .= '<div class="alert alert-danger alert-dismissable">';
        $cadena .= '<button class="close" aria-hidden="true" data-dismiss="alert" type="button"></button>';
        $cadena .= $error . $CI->session->flashdata('error');
        $cadena .= '</div>';
    }else if($success != null || $CI->session->flashdata('success') != ''){
        $cadena .= '<div class="alert alert-success alert-dismissable">';
        $cadena .= '<button class="close" aria-hidden="true" data-dismiss="alert" type="button"></button>';
        $cadena .= $success . $CI->session->flashdata('success');
        $cadena .= '</div>';
    }
    return $cadena;
}

function get_empresas_string(){
    $CI = & get_instance();
    $return = array();
    foreach($CI->session->userdata('empresas') as $empresa){
        $return[] = $empresa['emp_id'];
    }
    return implode(",", $return);
}
